package com.zsrt.java.day20170111.lh.daily.ch08;

import static org.junit.Assert.*;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.junit.Test;

/**
 * 输出今年星期二的日期
 * @author My
 *
 */
public class DateWeek2 {

	
	public static void main(String[] args) {
		
		//先找出今天是什么时候
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		cal.set(2017,0,01);
		while(cal.get(Calendar.YEAR)==2017){
			
			if(cal.get(Calendar.DAY_OF_WEEK)==7){
				System.out.println(sdf.format(cal.getTime()));
			}
			
			//DATE==DAY_OF_MONTH
			cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DATE)+1);
			
		}
		
	}
	
	
	/**
	 * 2013年1月1日距离今天有多少天?
	 * @throws Exception
	 */
	@Test
	public void testName() throws Exception {
		
		//先找出今天是什么时候
		Calendar cal = Calendar.getInstance();
		cal.set(2013,0,01);
		
		Date date=new Date();
		Date t1 = cal.getTime();
		date.setYear(2013);
		date.setMonth(0);
		date.setDate(01);
		
		long time = date.getTime();
		System.out.println(time);
		System.out.println(t1);
		
		
		
		Date d=new Date();
		cal.set(2017,0,11);
		long t2=d.getTime();
		Date time2=cal.getTime();
		
		
		System.out.println(time2);
		System.out.println(t2);

		
		
		long cha = time-t2;
		
		long a=cha/864000000;
		System.out.println("2013年1月1日距离今天有多少天?"+a);
		
		
		
	}
}
